﻿using System.ComponentModel.Composition;
using System.Windows;
using MediaAssistant.Controls.Dialog;
using MefBasic;

namespace MediaAssistant.Controls.MessageBox
{
    [Export]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class MessageBoxPresenter:APresenter<MessageBoxView>, IDialogContentPresenter
    {
        [ImportingConstructor]
        public MessageBoxPresenter(MessageBoxView view) : base(view)
        {
        }
        public DialogResult Show(string message, string title)
        {
            var dialogPresenter = Resolve<IDialogPresenter>();
            dialogPresenter.OkButtonCaption = OkButtonCaption;
            dialogPresenter.CancelButtonCaption = CancelButtonCaption;
            Message = message;
            return dialogPresenter.ShowDialog(title, this);
        }


        public string Message
        {
            get { return (string)GetValue(MessageProperty); }
            set { SetValue(MessageProperty, value); }
        }

        public static readonly DependencyProperty MessageProperty =
            DependencyProperty.Register("Message", typeof(string), typeof(MessageBoxPresenter), new UIPropertyMetadata(string.Empty));

        #region Implementation of IDialogContentPresenter

        public bool OnClosing(DialogResult dialogResult)
        {
            return true;
        }



        public string OkButtonCaption
        {
            get { return (string)GetValue(OkButtonCaptionProperty); }
            set { SetValue(OkButtonCaptionProperty, value); }
        }

        public static readonly DependencyProperty OkButtonCaptionProperty =
            DependencyProperty.Register("OkButtonCaption", typeof(string), typeof(MessageBoxPresenter), new UIPropertyMetadata("Ok"));




        public string CancelButtonCaption
        {
            get { return (string)GetValue(CancelButtonCaptionProperty); }
            set { SetValue(CancelButtonCaptionProperty, value); }
        }

        public static readonly DependencyProperty CancelButtonCaptionProperty =
            DependencyProperty.Register("CancelButtonCaption", typeof(string), typeof(MessageBoxPresenter), new UIPropertyMetadata("Cancel"));


        #endregion
    }
}
